home *** CD-ROM | disk | FTP | other *** search
- stop();
- makeFood();
- lc = level;
- this.onEnterFrame = function()
- {
- if(paused)
- {
- return undefined;
- }
- if(lc)
- {
- lc--;
- return undefined;
- }
- lc = level;
- x += vx;
- y += vy;
- if(x == fx && y == fy)
- {
- score += s_mc[x][y].fuse + 1;
- len++;
- with(s_mc[x][y])
- {
- fuse = len;
- gotoAndStop(1);
- }
- for(var i in s_mc)
- {
- for(var j in s_mc[i])
- {
- if(s_mc[i][j]._visible)
- {
- s_mc[i][j].fuse = s_mc[i][j].fuse + 1;
- }
- }
- }
- makeFood();
- }
- else if(s_mc[x][y]._visible || x == 0 || x == gx || y == 0 || y == gy || len > max)
- {
- gameOver = true;
- s_mc._alpha = 25;
- Key.removeListener(keyListener);
- nextFrame();
- delete this.onEnterFrame;
- }
- with(s_mc[x][y])
- {
- fuse = len;
- _visible = true;
- }
- moved = false;
- updateAfterEvent();
- };
- keyListener = new Object();
- keyListener.onKeyDown = function()
- {
- if(gameOver)
- {
- return undefined;
- }
- var keyCode = Key.getCode();
- switch(keyCode)
- {
- case Key.SPACE:
- case 80:
- case 112:
- paused = !paused;
- s_mc._alpha = !paused ? 100 : 25;
- }
- if(!paused && !moved)
- {
- switch(keyCode)
- {
- case Key.UP:
- if(vy == 0)
- {
- vx = 0;
- vy = - 1;
- moved = true;
- }
- break;
- case Key.DOWN:
- if(vy == 0)
- {
- vx = 0;
- vy = 1;
- moved = true;
- }
- break;
- case Key.LEFT:
- if(vx == 0)
- {
- vx = - 1;
- vy = 0;
- moved = true;
- }
- break;
- case Key.RIGHT:
- if(vx == 0)
- {
- vx = 1;
- vy = 0;
- moved = true;
- break;
- }
- }
- }
- };
- Key.addListener(keyListener);
-